#include <srts/stratego.h>
#include <stratego-lib/stratego-lib.h>
void init_constructors (void)
{
}
static Symbol sym__2;
static Symbol sym_Nil_0;
static Symbol sym_SVar_1;
static Symbol sym_SDefNoArgs_2;
static Symbol sym_SDef_3;
static Symbol sym_RDefNoArgs_2;
static Symbol sym_RDef_3;
static void init_module_constructors (void)
{
sym__2 = ATmakeSymbol("", 2, ATfalse);
ATprotectSymbol(sym__2);
sym_Nil_0 = ATmakeSymbol("Nil", 0, ATfalse);
ATprotectSymbol(sym_Nil_0);
sym_SVar_1 = ATmakeSymbol("SVar", 1, ATfalse);
ATprotectSymbol(sym_SVar_1);
sym_SDefNoArgs_2 = ATmakeSymbol("SDefNoArgs", 2, ATfalse);
ATprotectSymbol(sym_SDefNoArgs_2);
sym_SDef_3 = ATmakeSymbol("SDef", 3, ATfalse);
ATprotectSymbol(sym_SDef_3);
sym_RDefNoArgs_2 = ATmakeSymbol("RDefNoArgs", 2, ATfalse);
ATprotectSymbol(sym_RDefNoArgs_2);
sym_RDef_3 = ATmakeSymbol("RDef", 3, ATfalse);
ATprotectSymbol(sym_RDef_3);
}
static void init_module_constant_terms (void)
{
}
#include <srts/init-stratego-application.h>
extern const char * __tracing_table [];
extern unsigned short __tracing_table_counter;
ATerm try_1_0 (StrSL sl, StrCL x_40, ATerm t);
ATerm env_topdown_1_0 (StrSL sl, StrCL r_32, ATerm t);
ATerm io_wrap_1_0 (StrSL sl, StrCL z_25, ATerm t);
ATerm ReplaceStrategoMain_0_0 (StrSL sl, ATerm t);
static ATerm lifted1 (StrSL sl, ATerm t);
static ATerm lifted0 (StrSL sl, ATerm t);
ATerm main_0_0 (StrSL sl, ATerm t);
ATerm ReplaceStrategoMain_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "ReplaceStrategoMain_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
ATerm trm0 = t;
ATerm k_9 = NULL;
if(match_cons(t, sym__2))
{
ATerm trm1 = ATgetArgument(t, 0);
if(match_cons(trm1, sym_SVar_1))
{
ATerm trm2 = ATgetArgument(trm1, 0);
if(!((ATgetSymbol(trm2) == ATmakeSymbol("main", 0, ATtrue))))
goto label1 ;
}
else
goto label1 ;
k_9 = ATgetArgument(t, 1);
}
else
goto label1 ;
t = (ATerm) ATmakeAppl(sym__2, (ATerm)ATmakeAppl(sym_SVar_1, k_9), k_9);
goto label0 ;
label1 :
t = trm0;
{
ATerm trm3 = t;
ATerm i_9 = NULL,j_9 = NULL;
if(match_cons(t, sym__2))
{
ATerm trm4 = ATgetArgument(t, 0);
if(match_cons(trm4, sym_SDefNoArgs_2))
{
ATerm trm5 = ATgetArgument(trm4, 0);
if(!((ATgetSymbol(trm5) == ATmakeSymbol("main", 0, ATtrue))))
goto label2 ;
i_9 = ATgetArgument(trm4, 1);
}
else
goto label2 ;
j_9 = ATgetArgument(t, 1);
}
else
goto label2 ;
t = (ATerm) ATmakeAppl(sym__2, (ATerm)ATmakeAppl(sym_SDefNoArgs_2, j_9, i_9), j_9);
goto label0 ;
label2 :
t = trm3;
{
ATerm trm6 = t;
ATerm f_9 = NULL,g_9 = NULL,h_9 = NULL;
if(match_cons(t, sym__2))
{
ATerm trm7 = ATgetArgument(t, 0);
if(match_cons(trm7, sym_SDef_3))
{
ATerm trm8 = ATgetArgument(trm7, 0);
if(!((ATgetSymbol(trm8) == ATmakeSymbol("main", 0, ATtrue))))
goto label3 ;
f_9 = ATgetArgument(trm7, 1);
g_9 = ATgetArgument(trm7, 2);
}
else
goto label3 ;
h_9 = ATgetArgument(t, 1);
}
else
goto label3 ;
t = (ATerm) ATmakeAppl(sym__2, (ATerm)ATmakeAppl(sym_SDef_3, h_9, f_9, g_9), h_9);
goto label0 ;
label3 :
t = trm6;
{
ATerm trm9 = t;
ATerm d_9 = NULL,e_9 = NULL;
if(match_cons(t, sym__2))
{
ATerm trm10 = ATgetArgument(t, 0);
if(match_cons(trm10, sym_RDefNoArgs_2))
{
ATerm trm11 = ATgetArgument(trm10, 0);
if(!((ATgetSymbol(trm11) == ATmakeSymbol("main", 0, ATtrue))))
goto label4 ;
d_9 = ATgetArgument(trm10, 1);
}
else
goto label4 ;
e_9 = ATgetArgument(t, 1);
}
else
goto label4 ;
t = (ATerm) ATmakeAppl(sym__2, (ATerm)ATmakeAppl(sym_RDefNoArgs_2, e_9, d_9), e_9);
goto label0 ;
label4 :
t = trm9;
{
ATerm a_9 = NULL,b_9 = NULL,c_9 = NULL;
if(match_cons(t, sym__2))
{
ATerm trm12 = ATgetArgument(t, 0);
if(match_cons(trm12, sym_RDef_3))
{
ATerm trm13 = ATgetArgument(trm12, 0);
if(!((ATgetSymbol(trm13) == ATmakeSymbol("main", 0, ATtrue))))
goto fail3 ;
a_9 = ATgetArgument(trm12, 1);
b_9 = ATgetArgument(trm12, 2);
}
else
goto fail3 ;
c_9 = ATgetArgument(t, 1);
}
else
goto fail3 ;
t = (ATerm) ATmakeAppl(sym__2, (ATerm)ATmakeAppl(sym_RDef_3, c_9, a_9, b_9), c_9);
goto label0 ;
}
}
}
}
label0 :
;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail3 :
--__tracing_table_counter;
return(NULL);
}
ATerm main_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "main_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
struct str_closure t_113 = { &(lifted0) , &(frame) };
StrCL lifted0_cl = &(t_113);
t = io_wrap_1_0(sl, lifted0_cl, t);
if((t == NULL))
goto fail0 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail0 :
--__tracing_table_counter;
return(NULL);
}
static ATerm lifted0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "lifted0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
ATerm p_113 = NULL,q_113 = NULL;
struct str_closure s_113 = { &(lifted1) , &(frame) };
StrCL lifted1_cl = &(s_113);
if(match_cons(t, sym__2))
{
q_113 = ATgetArgument(t, 0);
p_113 = ATgetArgument(t, 1);
}
else
goto fail1 ;
t = (ATerm) ATmakeAppl(sym__2, p_113, q_113);
t = env_topdown_1_0(sl_up(sl), lifted1_cl, t);
if((t == NULL))
goto fail1 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail1 :
--__tracing_table_counter;
return(NULL);
}
static ATerm lifted1 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "lifted1";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
struct str_closure r_113 = { &(ReplaceStrategoMain_0_0) , sl_up(sl_up(sl)) };
StrCL lifted2_cl = &(r_113);
t = try_1_0(sl_up(sl_up(sl)), lifted2_cl, t);
if((t == NULL))
goto fail2 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail2 :
--__tracing_table_counter;
return(NULL);
}
static void register_strategies (void)
{
int initial_size = 117;
int max_load = 75;
struct str_closure * closures;
int closures_index = 0;
if((strategy_table == NULL))
strategy_table = ATtableCreate(initial_size, max_load);
closures = (struct str_closure*) malloc((sizeof(struct str_closure) * 7));
if((closures == NULL))
{
perror("malloc error for registration of dynamic strategies");
exit(1);
}
closures[closures_index].fun = &(try_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("try_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(env_topdown_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("env_topdown_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(io_wrap_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("io_wrap_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(ReplaceStrategoMain_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("ReplaceStrategoMain_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(lifted1);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("lifted1", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(lifted0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("lifted0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(main_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("main_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
}
int main (int argc, char * argv [])
{
ATerm out_term;
ATermList in_term;
int i;
ATinit(argc, argv, &(out_term));
init_constructors();
in_term = ATempty;
for ( i = (argc - 1) ; (i >= 0) ; i-- )
{
in_term = ATinsert(in_term, (ATerm) ATmakeAppl0(ATmakeSymbol(argv[i], 0, ATtrue)));
}
SRTS_stratego_initialize();
memset(__tracing_table, 0, (sizeof(unsigned short) * TRACING_TABLE_SIZE));
__tracing_table_counter = 0;
register_strategies();
out_term = main_0_0(NULL, (ATerm) in_term);
if((out_term != NULL))
{
ATfprintf(stdout, "%t\n", out_term);
exit(0);
}
else
{
ATfprintf(stderr, "%s: rewriting failed, trace:\n", argv[0]);
for ( i = 0 ; (__tracing_table[i] && (i < TRACING_TABLE_SIZE)) ; i++ )
ATfprintf(stderr, "\t%s\n", __tracing_table[i]);
exit(1);
}
}
